package config

import (
	"github.com/spf13/viper"
	"log"
)

type Config struct {
	Mysql
	ALiYun
	BaiDu
}
type BaiDu struct {
	ApiKey    string
	SecretKey string
}
type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Data     string
}
type ALiYun struct {
	AccessKeyID     string
	AccessKeySecret string
	Region          string
	BucketName      string
}

var Conf *Config

func AppConfig() {
	viper.SetConfigFile("./config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		panic(err)
	}
	log.Println("配置成功", Conf)
}
